﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtBlipDIB : OfficeArtStandardBlip
    {
        public OfficeArtBlipDIB(byte[] data): base (data)
        {
            this.NativeFormat = DibType.OneUid;
        }

        public OfficeArtBlipDIB() : base()
        {
        }

        public override RecType RecordType
        {
            get { return RecType.OfficeArtBlipDIB; }
        }


        protected override string Extension
        {
            get { return "dib"; }
        }

        protected override UidCount HasTwoIds()
        {
            DibType type = (DibType)this.NativeFormat;
            switch (type)
            {
                case DibType.OneUid:
                    return UidCount.One;
                case DibType.TwoUids:
                    return UidCount.Two;
                default: throw new NotSupportedException();
            }
        }
        private DibType _nativeFormat;

        private DibType NativeFormat
        {
            get
            {
                Contract.Ensures(Enum.IsDefined(typeof(DibType), Contract.Result<DibType>()));
                return _nativeFormat;
            }
            set
            {
                Contract.Requires(Enum.IsDefined(typeof (DibType), value));
                _nativeFormat = value;
            }
        }
        
        protected override ushort Format
        {
            get
            {
                return (ushort) NativeFormat;
            }
            set
            {
                NativeFormat = (DibType) value;
            }
        }

        internal override MSOBLIPTYPE Type
        {
            get { return MSOBLIPTYPE.msoblipDIB; }
        }

        enum DibType: ushort
        {
            OneUid = 0x7A8,
            TwoUids = 0x7A9
        }



    }
}